<template>

  <div class="dan" @click="isClick?goDetail():''">
    <template v-if="text_val_one.length>0">
      <!--              <span>{{scope.row.customer}}{{scope.row.catename?'/'+scope.row.catename:''}}</span>-->
      <template v-if="text_val_Num>defaults_text_Num">
        <el-popover placement="bottom" trigger="hover" :open-delay="300" popper-class="margin_top0"
                    :width="popoverWidth">
          <div class="common_remarks_box">
            <pre>{{text_val_one}}{{text_val_two?text_val_two:''}}</pre>
          </div>
          <template v-if="text_val_two.length>0">
            <div slot="reference" class="" :class="className">{{(text_val_one+text_val_two).substr(0,defaults_text_Num)}}<span>...</span>
            </div>
          </template>
          <template v-else>
            <div slot="reference" class="" :class="className">{{text_val_one.substr(0,defaults_text_Num)}}<span>...</span>
            </div>
          </template>

        </el-popover>
      </template>
      <template v-else>
        <div class="" :class="className">{{text_val_one}}{{text_val_two}}</div>
      </template>

    </template>
    <template v-else>
      <div class="" :class="className">-</div>
    </template>
  </div>
</template>
<script>
  var _this
  export default {
    name: 'TextOverflow',
    data() {
      return {
        text_val_one: this.textValOne,
        text_val_two: this.textValTwo,
        text_val_Num: this.textValNum,
        defaults_text_Num: this.defaultsNum,
      }
    },
    props: {
      textValOne: {
        type: String,
        default: ''
      },
      textValTwo: {
        type: String,
        default: ''
      },
      textValNum: {
        type: Number,
        default: 0
      },
      defaultsNum: {
        type: Number,
        default: 9
      },
      popoverWidth: {
        type: Number,//数据类型
        defaults: 300
      },
      className: {
        type: String,
        default: ''
      },
      isClick: {
        type: Boolean,
        default: false
      },
    },
    created: function() { //html加载完成之前
      _this = this
    },
    mounted: function() {

    },
    methods: {
      //跳转页面
      goDetail:function() {
        this.$emit("newClick");
      }
    },
    watch: {
      textValOne() {
        this.text_val_one = this.textValOne;
      },
      textValTwo() {
        this.text_val_two = this.textValTwo;
      },
      defaultsNum() {
        this.defaults_text_Num = this.defaultsNum;
      },
      textValNum() {
        this.text_val_Num = this.textValNum;
      },
    }
  }
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
  .dan {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
  }

  .common_remarks_box {
    padding: 14px 16px 10px 16px;
    width: 100%;
    box-sizing: border-box;
    cursor: pointer;
    max-height: 200px;
    overflow-y: auto;
  }

  .common_remarks_box::-webkit-scrollbar {
    width: 8px;
    height: 10px;
    background-color: rgba(0, 0, 0, 0)
  }

  .common_remarks_box::-webkit-scrollbar-thumb {
    border-radius: 6px;
    background-color: rgba(0, 0, 0, .2);
    transition: all .4s ease;
    -moz-transition: all .4s ease;
    -webkit-transition: all .4s ease;
    -o-transition: all .4s ease
  }

  .common_remarks_box::-webkit-scrollbar-track {
    background-color: rgba(0, 0, 0, .1)
  }

  .common_remarks_box pre {
    font-size: 12px;
    text-align: justify;
    line-height: 18px;
    color: #354168;
    white-space: pre-wrap;
    overflow-wrap: break-word;
  }
  .color-bl {
    color: #1CBECC !important;
  }
</style>
